package com.jzl.canal_consumer.config;

import com.jzl.canal_consumer.etl.load.mysql.DbDialect;
import com.jzl.canal_consumer.etl.load.mysql.SqlTemplate;
import com.jzl.canal_consumer.etl.load.mysql.impl.AbstractDbDialect;
import com.jzl.canal_consumer.etl.load.mysql.impl.MysqlSqlTemplate;
import com.jzl.util.HttpClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.support.lob.DefaultLobHandler;
import org.springframework.jdbc.support.lob.LobHandler;


/**
 * @author zwwang
 */
@Configuration
public class DataSourceBeanConfig
{
    @Bean
    public LobHandler lobHandler()
    {
        DefaultLobHandler defaultLobHandler = new DefaultLobHandler();
        defaultLobHandler.setStreamAsLob(true);
        return defaultLobHandler;
    }


    @Bean
    public DbDialect dbDialect(JdbcTemplate jdbcTemplate, LobHandler lobHandler)
    {
        return new AbstractDbDialect(jdbcTemplate, lobHandler)
        {
        };
    }

    @Bean
    public SqlTemplate sqlTemplate()
    {
        return new MysqlSqlTemplate();
    }

    @Bean
    public HttpClient httpClient()
    {
        return new HttpClient();
    }
}
